var app = getApp();
Component({
  data: {
    selected: '0',
    index:'0',
    color: "#7A7E83", // 颜色
    selectedColor: "#1E70E1", // 被选中颜色
    list: [{
      "pagePath": "/pages/index/index",
      "iconPath": "../images/home.png",
      "selectedIconPath": "../images/home-active.png"
    },
    {
      "pagePath": "/pages/user/index",
      "iconPath": "../images/user.png",
      "selectedIconPath": "../images/user-active.png"
    }
    ]
  },
  attached() {},
  methods: {
    switchTab(e) {
      var url = e.currentTarget.dataset.path
      var index=e.currentTarget.dataset
      app.globalData.selectedIndex =e.currentTarget.dataset.index
      this.setData({
        selected: e.currentTarget.dataset.index
      })
      // 根据index判断，发布是渲染的时候是没有url的
      if (url) {
        wx.switchTab({
          url
        })
      }     
    }
  }
})